import uvicorn
from mcp.server.fastmcp import FastMCP
from starlette.applications import Starlette
from starlette.routing import Mount

from application.sd_base_mcp_v1.prompt.coding_mcp_prompt import SDCodingPrompt
from application.sd_base_mcp_v1.tool.common.interface_mcp_tool import interface_tool
from application.sd_base_mcp_v1.tool.entity.entity_code_mcp_tool import EntityCodeMcpTool

mcp_server = FastMCP(
    name='tqt-activity-development-basic-mcp-server-sd-v1',
)
# 提示词工具
mcp_server.add_tool(
    fn=SDCodingPrompt.entity_go_prompt,
    name='entity.go编码提示词',
    description='entity.go编码提示词'
)

# 开发工具
mcp_server.add_tool(
    fn=EntityCodeMcpTool.handler,
    name='excel工具',
    description='读取excel中的配置项并返回拆分后的配置项markdown'
)

mcp_server.add_tool(
    fn=interface_tool,
    name='接口工具',
    description='提供接口名称将返回需要接口详细信息'
)

app = Starlette(
    routes=[
        Mount('/', app=mcp_server.sse_app()),
    ]
)

if __name__ == '__main__':
    # 启动前先注释以下代码
    # mcp/server/session.py:161
    uvicorn.run(app, host='127.0.0.1', port=8000)
